import * as React from 'react'
import classNames from 'classnames'
import './style/index.less'
import { IconProps, IconState } from './interface'

export default class Icon extends React.Component<IconProps, IconState> {
  static defaultProps = {
    prefixCls: 'layui-icon'
  }
  constructor(props: IconProps) {
    super(props);
    this.state = {

    }
  }

  render() {

    const {
      prefixCls, 
      className, 
      type, 
      size, 
      onClick,
      ...restProps
    } = this.props


    let sizeCls = ''
    switch (size) {
      case 'large':
        sizeCls = 'lg'
        break;
      case 'small':
        sizeCls = 'sm'
        break;
      default:
        break;
    }

    // 计算classname
    const classes = classNames(prefixCls, className, {
      [`${prefixCls}-${type}`]: type,
      [`layui-size-${sizeCls}`]: sizeCls
    })
    return (
      <i
        className={classes}
        onClick={onClick}
        {...restProps}
      ></i>
    )
  }
}